Skip to content

feat: reuse existing Devin sessions when resolving conflicts#26711

Merged
anikdhabal merged 6 commits intomainfrom
devin/1768098824-conflict-resolver-session-reuse
Jan 11, 2026
Merged

feat: reuse existing Devin sessions when resolving conflicts#26711
anikdhabal merged 6 commits intomainfrom
devin/1768098824-conflict-resolver-session-reuse

Conversation

@anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Jan 11, 2026

What does this PR do?

Updates the devin-conflict-resolver.yml workflow to reuse existing Devin sessions instead of always creating new ones when a PR has merge conflicts. This follows the same pattern used in cubic-devin-review.yml.

The workflow now:

  1. Checks if the PR was created through Devin (session URL in PR body) - always uses that session
  2. Checks PR comments for existing sessions (both conflict resolution and Cubic AI review sessions) and verifies they're active
  3. Sends a message to the existing session instead of creating a new one
  4. Only creates a new session if no active session exists

Updates since last revision

  • Added support for reusing Cubic AI review sessions (comments containing "Devin AI is addressing Cubic AI") in addition to conflict resolution sessions
  • Fixed potential TypeError by adding optional chaining for comment.body (Cubic AI review feedback)
  • Removed premature break statement to allow checking all comments for active sessions when earlier sessions are inactive (Cubic AI review feedback)
  • Simplified comment structure: both new and existing sessions now show the same full comment with all details, only the status message differs ("A Devin session has been created..." vs "The existing Devin session has been notified...")

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - workflow change only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. N/A - GitHub Actions workflow, tested via production runs.

How should this be tested?

This is a GitHub Actions workflow change. To test:

  1. Find a PR with merge conflicts that already has a Devin session from a previous conflict resolution attempt OR a Cubic AI review
  2. Trigger the workflow manually or wait for the scheduled run
  3. Verify the workflow sends a message to the existing session instead of creating a new one
  4. Check that the PR comment reflects "existing Devin session has been notified" rather than "session has been created"

Human Review Checklist

  • Verify findExistingSession() correctly prioritizes PR body session over comment sessions
  • Verify active status check (['working', 'blocked', 'resumed']) matches expected Devin API statuses
  • Verify both session patterns are correct:
    • 'Devin AI is resolving merge conflicts' for conflict resolution
    • 'Devin AI is addressing Cubic AI' for Cubic AI reviews
  • Verify Devin API endpoints are correct (/v1/sessions/{id} for status, /v1/sessions/{id}/message for messaging)
  • Optional chaining for comment.body to prevent TypeError (fixed)
  • Loop continues checking all comments when a session is inactive (fixed)

- Check if PR was created through Devin and use that session
- Check PR comments for existing active Devin sessions
- Send message to existing session instead of creating new one
- Only create new session if no active session exists
- Update comment message to reflect whether session is new or reused

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 2 commits January 11, 2026 02:48
…ions

- Added 'Devin AI is addressing Cubic AI' to session patterns
- Now checks for both conflict resolution and Cubic AI review sessions

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@anikdhabal anikdhabal marked this pull request as ready for review January 11, 2026 04:33
@anikdhabal anikdhabal requested review from a team as code owners January 11, 2026 04:33
@graphite-app graphite-app bot added the core area: core, team members only label Jan 11, 2026
@anikdhabal anikdhabal enabled auto-merge (squash) January 11, 2026 04:33
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".github/workflows/devin-conflict-resolver.yml">

<violation number="1" location=".github/workflows/devin-conflict-resolver.yml:263">
P2: Potential TypeError if `comment.body` is null. Use optional chaining to safely access the body, consistent with the `prBody?.match()` pattern used earlier.</violation>

<violation number="2" location=".github/workflows/devin-conflict-resolver.yml:280">
P2: The `break` statement is placed outside the active status check, causing the loop to exit even when a found session is inactive. This prevents finding other potentially active sessions from earlier comments. Either remove the `break` to check all sessions, or move it inside the success case.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session

devin-ai-integration bot and others added 2 commits January 11, 2026 04:38
- Add optional chaining for comment.body to prevent TypeError
- Remove break statement to allow checking all comments for active sessions

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
Comment on lines +427 to +437
: `### Devin AI is resolving merge conflicts

This PR has new merge conflicts with the \`${pr.base_ref}\` branch. The existing Devin session has been notified to resolve them.

[View Devin Session](${sessionUrl})`;

await github.rest.issues.createComment({
owner,
repo,
issue_number: pr.number,
body: commentBody
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DevinAI, can you explain why you made this change from the previous one? Is it needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this change is needed to differentiate between two scenarios:

  1. New session created: The original comment says "A Devin session has been created to automatically resolve them" and lists all the steps Devin will take
  2. Existing session reused: The new shorter comment says "The existing Devin session has been notified to resolve them"

This distinction is important because:

  • When reusing an existing session, we're just sending a message to an already-running session, not creating a new one
  • The shorter message avoids redundantly listing all the steps again (the user already saw those when the session was first created)
  • It makes it clear to PR reviewers that no new session was spawned - we're just continuing work in the existing one

This follows the same pattern used in cubic-devin-review.yml (lines 224-226) which also has different comment messages for new vs. existing sessions.

Copy link
Contributor Author

@anikdhabal anikdhabal Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DevinAI No, we don’t want a refactor here. Keep it as it is, like before. The only change I want is: when a new session is created, show “A Devin session has been created to automatically resolve them,” and if not, show “The existing Devin session has been notified to resolve them.”

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I've updated the code to keep the same full comment structure for both cases. Now both new and existing session comments will show the complete list of what Devin will do, with only the status message differing:

  • New session: "A Devin session has been created to automatically resolve them."
  • Existing session: "The existing Devin session has been notified to resolve them."

Pushed in commit 16b1fa8.

- Both new and existing session comments now show the full list of what Devin will do
- Only the status message differs: 'created' vs 'notified'

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@anikdhabal anikdhabal added this to the v6.1 milestone Jan 11, 2026
@anikdhabal anikdhabal merged commit 1e98652 into main Jan 11, 2026
73 of 75 checks passed
@anikdhabal anikdhabal deleted the devin/1768098824-conflict-resolver-session-reuse branch January 11, 2026 14:08
Anshumancanrock pushed a commit to Anshumancanrock/cal.com that referenced this pull request Jan 12, 2026
…26711)

* feat: reuse existing Devin sessions when resolving conflicts

- Check if PR was created through Devin and use that session
- Check PR comments for existing active Devin sessions
- Send message to existing session instead of creating new one
- Only create new session if no active session exists
- Update comment message to reflect whether session is new or reused

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* feat: also check for Cubic AI review sessions when reusing Devin sessions

- Added 'Devin AI is addressing Cubic AI' to session patterns
- Now checks for both conflict resolution and Cubic AI review sessions

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – dev January 13, 2026 08:27 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only ready-for-e2e size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants